package tech.aistar.controller.personal;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import tech.aistar.entity.personal.User;
import tech.aistar.service.personal.IUserService;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * Created by LJX on 2019/9/26.
 */
@Controller
@RequestMapping("/user")
public class LoadController {
    @Autowired
    private IUserService iUserService;
    @RequestMapping("/loadView")
    public String loadView(){
        return "personal/login";
    }
    @RequestMapping("/loadList")
    public String loadList(Model model, User u, HttpServletResponse resp, HttpServletRequest req) {
        User user = iUserService.findByName(u.getUsername());
        if (user.getPassword().equals(u.getPassword())) {

            return "../../index";


        } else {
            return "redirect:loadView?error=1";
        }


    }
}
